package com.pan.common.interview.thread.synchronize;

/**
 * 锁：
 * 1、保证只有一个线程执行对应代码块
 * 2、修改内容对其他线程可见
 *
 * 对象锁（只首当前对象的制约）
 * 类锁（对当前类的所有对象，都有限制）
 *
 * 类锁和对象锁是互不干扰的
 */
public class SyncDemo {

    public static void main(String... args) {
        SyncThread syncThread = new SyncThread();
        //没有锁
        Thread A_thread1 = new Thread(syncThread, "A_thread1");
        Thread A_thread2 = new Thread(syncThread, "A_thread2");

        //
        Thread B_thread1 = new Thread(syncThread, "B_thread1");
        Thread B_thread2 = new Thread(syncThread, "B_thread2");
        Thread C_thread1 = new Thread(syncThread, "C_thread1");
        Thread C_thread2 = new Thread(syncThread, "C_thread2");
        Thread D_thread1 = new Thread(syncThread, "D_thread1");
        Thread D_thread2 = new Thread(syncThread, "D_thread2");
        Thread E_thread1 = new Thread(syncThread, "E_thread1");
        Thread E_thread2 = new Thread(syncThread, "E_thread2");
        A_thread1.start();
        A_thread2.start();
        B_thread1.start();
        B_thread2.start();
        C_thread1.start();
        C_thread2.start();
        D_thread1.start();
        D_thread2.start();
        E_thread1.start();
        E_thread2.start();
    }
}
